namespace KinonekoSoftware.Extensions.Reflections
{
    /// <summary>
    /// 实现高效的获取指定的枚举类型中所有的字段。
    /// </summary>
    /// <typeparam name="T">指定的枚举类型。</typeparam>
    // ReSharper disable once ClassNeverInstantiated.Global
    public sealed class EnumValuesFactory<T> where T : struct, Enum
    {
        private static readonly Lazy<IEnumerable<T>> _factory = new Lazy<IEnumerable<T>>(ClassStatic.GetEnums<T>);

        /// <summary>
        /// 获取枚举的所有字段。
        /// </summary>
        public static IEnumerable<T> Values => _factory.Value;
    }
}